home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / dup.man < prev    next >
Encoding:
Text File  |  1989-01-06  |  2.3 KB  |  67 lines

  1.  
  2.  
  3.  
  4. DUP                   C Library Procedures                    DUP
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      dup, dup2 - duplicate a descriptor
  10.  
  11. SSYYNNOOPPSSIISS
  12.      nneewwdd == dduupp((oolldddd))
  13.      iinntt nneewwdd,, oolldddd;;
  14.  
  15.      dduupp22((oolldddd,, nneewwdd))
  16.      iinntt oolldddd,, nneewwdd;;
  17.  
  18. DDEESSCCRRIIPPTTIIOONN
  19.      _D_u_p duplicates an existing object descriptor.  The argument
  20.      _o_l_d_d is a small non-negative integer index in the per-
  21.      process descriptor table.  The value must be less than the
  22.      size of the table, which is returned by _g_e_t_d_t_a_b_l_e_s_i_z_e(2).
  23.      The new descriptor returned by the call, _n_e_w_d, is the lowest
  24.      numbered descriptor that is not currently in use by the pro-
  25.      cess.
  26.  
  27.      The object referenced by the descriptor does not distinguish
  28.      between references using _o_l_d_d and _n_e_w_d in any way.  Thus if
  29.      _n_e_w_d and _o_l_d_d are duplicate references to an open file,
  30.      _r_e_a_d(2), _w_r_i_t_e(2) and _l_s_e_e_k(2) calls all move a single
  31.      pointer into the file, and append mode, non-blocking I/O and
  32.      asynchronous I/O options are shared between the references.
  33.      If a separate pointer into the file is desired, a different
  34.      object reference to the file must be obtained by issuing an
  35.      additional _o_p_e_n(2) call.  The close-on-exec flag on the new
  36.      file descriptor is unset.
  37.  
  38.      In the second form of the call, the value of _n_e_w_d desired is
  39.      specified.  If this descriptor is already in use, the
  40.      descriptor is first deallocated as if a _c_l_o_s_e(2) call had
  41.      been done first.
  42.  
  43. RREETTUURRNN VVAALLUUEE
  44.      The value -1 is returned if an error occurs in either call.
  45.      The external variable _e_r_r_n_o indicates the cause of the
  46.      error.
  47.  
  48. EERRRROORRSS
  49.      _D_u_p and _d_u_p_2 fail if:
  50.  
  51.      [EBADF]        _O_l_d_d or _n_e_w_d is not a valid active descriptor
  52.  
  53.      [EMFILE]       Too many descriptors are active.
  54.  
  55. SSEEEE AALLSSOO
  56.      accept(2), open(2), close(2), fcntl(2), pipe(2), socket(2),
  57.      socketpair(2), getdtablesize(2)
  58.  
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 13, 1986                          1
  64.  
  65.  
  66.  
  67.